﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using Common;

public partial class Customer_UnCommend_Add : System.Web.UI.Page
{
    protected int ID;

    protected string MenuType
    {
        get { return string.IsNullOrEmpty(Request["menutype"]) ? "" : Request["menutype"].ToString(); }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        ID = string.IsNullOrEmpty(Request["ID"]) ? 0 : Convert.ToInt32(Request["ID"]);

        if (!this.IsPostBack)
        {

            if (ID != 0)
            {
                Dat_UnCommend uncommand = new UnCommend().SelectUnCommend(ID);
                txt_TOPIC.Text = uncommand.TOPIC;
                txt_CONTENT.Text = uncommand.CONTENT;
                txt_TOCONTENT.Text = uncommand.TOCONTENT;
                txt_STATE.SelectedValue = uncommand.STATE.ToString();

                btnSubmit.Text = "回 复";
            }
       }
    }

    //添加
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        DateTime? de = null;

        if (ID == 0)
        {
            Dat_UnCommend uncommend = new Dat_UnCommend
            {
                TOPIC = txt_TOPIC.Text.Trim(),
                CONTENT = txt_CONTENT.Text.Trim(),
                TOCONTENT = "",
                USERKEY = Convert.ToInt32(Session["UserKey"]),
                CREATETIME = DateTime.Now,
                STATE = 0
            };
             if (new UnCommend().AddUnCommend(uncommend) )
            {
                WebUtility.JsAlertToGo("投诉成功", "UnCommend_Add.aspx?menutype=431");
            }
        }
        else
        {
            Dat_UnCommend uncommend = new Dat_UnCommend
            {   
                ID = ID,
                TOCONTENT = txt_TOCONTENT.Text.Trim(),
                STATE = Convert.ToInt32(txt_STATE.SelectedValue)
            };

            if (new UnCommend().EditUnCommend(uncommend))
            {
                WebUtility.JsAlertToGo("回复投诉成功", "UnCommend.aspx?menutype=432");
            }
        }
    }

}
